package cn.agiledata.bank.netReturn.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import cn.agiledata.bank.common.util.ForeDict;
import cn.agiledata.bank.netReturn.logic.NetReturnResponse;
import cn.agiledata.bank.netReturn.service.NetReturnService;
import com.vnv.infrastructure.action.IPBBaseAction;
import com.vnv.infrastructure.exception.IPBException;
import com.vnv.infrastructure.logic.IPBAppFactory;

public class NetReturnResponseAction extends IPBBaseAction {

	public int hasAccessPermission(int accessLevel, HttpServletRequest request)
    throws IPBException {
		return 1;
	}
	
	private NetReturnService getReturnMoneyService() {
        return (NetReturnService) IPBAppFactory.getObj(ForeDict.SERVICE_NET_RETURN);
    }
	
	public ActionForward netReturnResponse(ActionMapping mapping,
            ActionForm actionForm, HttpServletRequest request,
            HttpServletResponse response) throws Exception {
		NetReturnResponse netReturn = (NetReturnResponse)request.getSession().getAttribute("netReturnResponse");
		request.getSession().removeAttribute("netReturnResponse");
		if (netReturn != null){
			netReturn = getReturnMoneyService().backgroundResponse(netReturn);
			request.setAttribute("netReturnResponse", netReturn);
		}
		return mapping.findForward("response");
	}
}
